[ADD] estate,estate_account: technical onboarding commit #1285
[ADD] estate,estate_account: technical onboarding commit #1285jupir-odoo wants to merge 1 commit into
Conversation
07fb131 to
2b8c4ec
Compare
|
@aboo-odoo kind reminder :D |
2b8c4ec to
5c36dbc
Compare
There was a problem hiding this comment.
Phenomenal work 🥳 I'm being extra-picky so that I can transmit as much information as possible. If there is anything you disagree with, please share it without fear.
Some comments apply at several places but I've only written it once to save some time and to not cumbersome the PR, when you check and update according to one of my comment, check that this comment does not apply elsewhere before moving to the next one 😄
A generic comment:
- your PR/commit body could be a little more exhaustive a good template is to follow is
STEPS to reproduce the bug (only for bugfixes)
PROBLEM - what is the problem
GOAL - what do we want to achieve
SOLUTION - how did we achieve it
task-XXXXXX
There was a problem hiding this comment.
In a Model attribute order should be:
- Private attributes (_name, _description, _inherit, …)
- Default method and default_get
- Field declarations
- SQL constraints and indexes
- Compute, inverse and search methods in the same order as field declaration
- Selection method (methods used to return computed values for selection fields)
- Constrains methods (@api.constrains) and onchange methods (@api.onchange)
- CRUD methods (ORM overrides)
- Action methods
- And finally, other business methods.
| copy=False, default=datetime.today() + relativedelta(months=3) | ||
| ) | ||
| expected_price = fields.Float(required=True) | ||
| _expected_price_constraint = models.Constraint( |
There was a problem hiding this comment.
The two constraints should be just after the _order attribute 😄
|
|
||
|
|
||
| class EstatePropery(models.Model): | ||
| _name = "estate.property" |
There was a problem hiding this comment.
There is a tacit convention that strings viewed by the users are surrounded by ", otherwise it is '
| _name = "estate.property" | |
| _name = 'estate.property' |
| garden_area = fields.Integer() | ||
| garden_orientation = fields.Selection( | ||
| string="Orientation", | ||
| selection=[("N", "North"), ("E", "East"), ("S", "South"), ("W", "West")], |
There was a problem hiding this comment.
Consider selection and a kind of dictionary, for dictionaries, you would write the keys in lower letters
| selection=[("N", "North"), ("E", "East"), ("S", "South"), ("W", "West")], | |
| selection=[('north', "North"), ('east', "East"), ('south', "South"), ('west', "West")], |
Also, don't hesitate to be exhaustive in your name; estate.garden_orientation = 'north' is a bit clearer than estate.garden_orientation = 'n'
| default="new", | ||
| ) | ||
|
|
||
| def action_cancel_property(self): |
There was a problem hiding this comment.
self is a recordset, i.e. a collection of records. Your method would failed if called on several records when trying to perform self.state.
Currently, through the UI, you cannot trigger the error, but from the command line or a server action, users could get the traceback.
side note: you can run odoo in terminal mode by adding shell after odoo-bin: python odoo-bin shell --addons-path .... From there, you could perform
estates = self.env['estate.property'].create([{'name': 'TEST1', ADD the other relevant key-value pairs}, {'name': 'TEST2', ADD the other relevant key-value pairs}])
estates.action_cancel_property() # This should trigger the traceback
There are two ways to solve the issue:
- begin your method with
self.ensure_one(), quite self explanatory - or use a for loop like in _compute methods
| ) | ||
|
|
||
| def action_accept(self): | ||
| if self.property_id.state == "sold": |
There was a problem hiding this comment.
What happens if the property is cancelled ?
| @api.model | ||
| def create(self, vals): |
There was a problem hiding this comment.
It would be preferable that you create the records in a batch rather than one by one, better performances 😄
| @api.model | |
| def create(self, vals): | |
| @api.model_create_multi | |
| def create(self, vals_list): |
| if float_compare(property.best_price, record["price"], 2) == 1: | ||
| raise UserError("You already have a higher offer") | ||
|
|
||
| if hasattr(property, "state"): |
There was a problem hiding this comment.
The property model always has the state attribute (you defined it as field), in what scenario could you not have one ?
| ], | ||
| "installable": True, | ||
| "application": True, | ||
| "author": "Julien (jupir)", |
There was a problem hiding this comment.
Everything you create for Odoo belongs to "Odoo S.A." hehe
| "author": "Julien (jupir)", | |
| "author": "Odoo S.A.", |
| delta = timedelta(days=offer.validity) | ||
| offer.date_deadline = ( | ||
| offer.create_date.date() + delta | ||
| if offer.create_date | ||
| else today() + delta | ||
| ) |
There was a problem hiding this comment.
Alternatively (one-liner)
| delta = timedelta(days=offer.validity) | |
| offer.date_deadline = ( | |
| offer.create_date.date() + delta | |
| if offer.create_date | |
| else today() + delta | |
| ) | |
| offer.date_deadline = (offer.create_date or today()).date() + timedelta(days=offer.validity) |
5c36dbc to
4fd2d3b
Compare
| description = fields.Text() | ||
| postcode = fields.Char() | ||
| date_availability = fields.Date( | ||
| copy=False, default=datetime.today() + relativedelta(months=3) |
There was a problem hiding this comment.
I've just noticed an issue here:
when declaring the default value like so, it will get computed once you start the database. The computed value will then be used until your database is restarted. This means that if you start your db today 26/05 and let it run for a month and that, on the 26/06 you create a new property record, the default date_availibility will be 26/08 (mai + 3 month) while we expect it to be 26/09 (june + 3 month).
To make the default value recomputed at each call; you need to call a function
4fd2d3b to
9001c34
Compare
Problem: There is currently no modules to manage real estate businesses in odoo. Solution: Implement estate properties, offer, tags, and types models with the associated views. task-6229399
9001c34 to
985deb6
Compare
|
Hello @aboo-odoo, j'ai appliqué tes conseils. Merci beaucoup. J'ai aussi fait le tuto sur les unit tests. Je ne sais pas si tu préfères que je les push aussi ici ou que je crée une deuxième PR. Merci d'avance ! |

[ADD] estate,estate_accountant: technical onboarding commit
Problem:
There is currently no modules to manage real estate businesses in odoo.
Solution:
Implement estate properties, offer, tags, and types models with the associated views.
task-6229399